为了在C1Chart中添加缩放行为,使用一些自定义代码在图表的MouseWheel事件处理中。
C# |
拷贝代码
|
---|---|
private void chart_MouseWheel(object sender, MouseWheelEventArgs e) { if (Keyboard.Modifiers == ModifierKeys.Control && e.Delta == -120) { chart.View.AxisX.Scale += .1; chart.View.AxisY.Scale += .1; } else if (Keyboard.Modifiers == ModifierKeys.Control && e.Delta == 120) { chart.View.AxisX.Scale -= .1; chart.View.AxisY.Scale -= .1; } } |
为了使得用户可以在缩放时在附近移动图表,添加以下内容至C1Chart的XAML标记:
XAML |
拷贝代码
|
---|---|
<c1c:C1Chart x:Name="chart" MouseWheel="chart_MouseWheel" > <c1c:C1Chart.Actions> <c1c:TranslateAction MouseButton="Left" /> </c1c:C1Chart.Actions> </c1c:C1Chart> |